package com.lujianfei.ann.network.layer;

import com.lujianfei.ann.network.activate.IActivateFunc;

public class Layer {

	private int nodeSize;
	private double[] n;
	private Weight outWeight;
	private double[] errors;
	private IActivateFunc activateFunc;
	public IActivateFunc getActivateFunc() {
		return activateFunc;
	}
	public void setActivateFunc(IActivateFunc activateFunc) {
		this.activateFunc = activateFunc;
	}
	public double[] getErrors() {
		return errors;
	}
	public void setErrors(double[] errors) {
		this.errors = errors;
	}
	public Layer(int nodeSize) {
		this.n = new double[nodeSize + 1];
	}
	public double[] getN() {
		return n;
	}
	public void setN(int index,double value) {
		this.n[index] = value;
	}
	public void setN(double[] n) {
		for (int i = 0; i < n.length; i++) {
			this.n[i + 1] = n[i];	
		}
	}
	
	public Weight getOutWeight() {
		return outWeight;
	}
	public void setOutWeight(Weight outWeight) {
		this.outWeight = outWeight;
	}

	public static class Builder{
		
		Layer layer;
		public Builder(int nodeSize) {
			layer = new Layer(nodeSize);
		}
		public Builder setOutWeight(Weight weight) {
			layer.outWeight = weight;
			return this;
		}
		public Builder setActivateFunc(IActivateFunc activateFunc) {
			layer.activateFunc = activateFunc;
			return this;
		}
		public Layer create() {
			return layer;
		}
	}
}
